package api
{
	import SEApp.se_app;
	
	import api_servers.api_server;
	
	import flash.events.Event;
	
	import vk.APIConnection;

	public class clt_vkserverConnection extends api_server {
		private var _flashVars: Object;
		private var _vk: APIConnection;			
		public function clt_vkserverConnection(a_sroot: se_app, _params: Object) {
			_flashVars = _params;
//access_token=6966419d25c9eec46b9807e9036be4955dd6bc76bc7497abc8b492b498710b5&api_id=2350118&api_settings=1&api_url=http%3A%2F%2Fapi.vkontakte.ru%2Fapi.php&auth_key=939e64b259975b1a4046b26321699ce2&group_id=0&hash=&is_app_user=1&language=0&lc_name=eeca3451&parent_language=0&referrer=profile&secret=f53aa17b71&sid=d93286dc68667c186335b46e4fc6d2709f2761bb88d4236a72c3fb11f7dd1c&user_id=44108006&viewer_id=44108006&viewer_type=2			
			if (!_flashVars.api_id) {
				_flashVars['api_id'] = 2350118;
				_flashVars['viewer_id'] = 44108006;
				_flashVars['sid'] = "d93286dc68667c186335b46e4fc6d2709f2761bb88d4236a72c3fb11f7dd1c";
				_flashVars['secret'] = "f53aa17b71";
			}			
			super(a_sroot, 'http://api.vkontakte.ru/api.php', _flashVars['viewer_id'], _flashVars['api_id'], _flashVars['secret']);
			
			_vk = new APIConnection(_flashVars);
		}
		
		override public function get flashVars(): Object {
			return _flashVars;
		}
		
		protected function doError(data: Object): void {
			trace(data);
		}
		
		public function get vk(): APIConnection {
			return _vk;
		}
		
		public function resizeWindow(width: uint, height: uint): void {
			_vk.callMethod('resizeWindow', width, height);
		}
		
		public function showSettingsBox(access: uint, _handle: Function): void {
			_vk.callMethod('showSettingsBox', access);
			_vk.addEventListener('onSettingsChanged', function(e: Event): void {
				_handle(e);
			});
		}
		
		public function getUserSettings(_handle: Function): void {
			_vk.api('getUserSettings', {}, _handle, doError);
		}
		
		
		public function getAlbums(uid: String, handler_:*): void {
	    	_vk.api('photos.getAlbums', {
	    	}, function(e: Object): void {
	    		handler_(e);
	    	}, doError);
		}
		
		public function getPhotos(uid: String, aid: String, handler_:*): void {
		}
		
	    public function getAllFriends(uid: String, handler_:*, queryID:String='getAllFriends'): void {
	    }

	    override public function getProfiles(uids: String, handler_:*, fields: String='', queryID:String=''): void {
	    }
	    
	    public function getAppUsers(handler_:*): void {
	    }	    
	}
}